package com.cloud.base.thread.semaphore;

import java.util.concurrent.Semaphore;

public class SemaphoreMain {

    // 类似于lock锁
    public static void main(String[] args) {
        Semaphore semp = new Semaphore(5);
        try {
            // 申请许可
            semp.acquire();
            try {
                // 业务逻辑
            } catch (Exception e) {

            } finally {
                // 释放许可
                semp.release();
            }
        } catch (InterruptedException e) {
        }
    }
}
